package parser_antlr4.aspect;

import cn.hutool.core.util.StrUtil;
import constant.SQLParserConstants;
import exception.SQLParseException;

import java.lang.reflect.Method;

public class ParserAspectSQLNotBlank implements ParserAspect {
  @Override
  public boolean enabled() {
    return true;
  }

  @Override
  public void beforeParse(Method method, Object[] args) throws SQLParseException {
    for (int i = 0; i < args.length; i++) {
      if (args[i] instanceof String) {
        if (StrUtil.isBlank((String) args[i])) {
          throw new SQLParseException(SQLParserConstants.SQL_NOT_BLANK);
        }
      }
    }
  }
}
